/*
 * IView.java
 *
 * Created on 20 October 2007, 11:13
 *
 */

package net.ubinow.mflex.baseui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import net.ubinow.mflex.events.IEventPublisher;

/**
 *
 * @author Josh
 */
public interface IWidget extends IEventPublisher {    
        
    public String getID();
    public void setID( String id );
    
    public int getX();
    public void setX( int x );
    
    public int getBottomY();
    public int getBottomY( boolean includeHeight );
    public int getY(); 
    public void setY( int y );
    
    /**
     * sets the x and y position of the object as well as sets the orginal X and y values (used in transitioning to save
     * processing ie having to remember the orginal position when manipulating x and y positions)
     * @param x
     * @param y
     */
    public void setOrgPos( int x, int y );
    
    public void setPos( int x, int y );
    
    /**
     * resets the orginal x and y values to the actual x and y positions of the widget
     */
    public void resetPos(); 
    
    public int getOrgX(); 
    public int getOrgY();
    
    public int getWidth();
    public void setWidth( int w );
    
    public int getHeight(); 
    public void setHeight( int h );
    
    public int getPaddingW();
    public void setPaddingW( int padding );
    public int getPaddingH();
    public void setPaddingH( int padding ); 
    
    public void setBG( Image bg );
    public void setBG( int colour ); 
    
    public void cycle(); 
    
    /**
     * @param g: graphics object to render on 
     * @param offsetX: adjustments to the x position of the view 
     * @param offsetY: adjustments to the y position of the view 
     * @param layer: the layer to render ie combo box layer 1 will render the box, combo box layer 2 will render the drop down
     **/
    public void paint( Graphics g, int offsetX, int offsetY, int layer );
    
    public boolean handleKeyPressed( int action, int keyCode ); 
    public boolean handleKeyReleased( int action, int keyCode );
    
    // TODO: maybe? public boolean handleLeftCommandPressed(); 
    // TODO: maybe? public boolean handleRightCommandPressed(); 
    
    public void setFont( WFont font ); 
    public WFont getFont(); 
    
    /** tells the controller that it is still visible so render it **/ 
    public boolean isVisible();    
    public void setIsVisible(boolean isVisible );
    
    /** returns the number of layers it takes to return this view **/ 
    public int maxLayers(); 
    
    /** width + padding **/ 
    public int getTotalHeight();
    
    /** height + padding */ 
    public int getTotalWidth();
    
    /** indicates whether the user can select/interact this view **/ 
    public boolean isSelectable(); 
    
    /** 
     * set to true when the user has selected this view, set to false when the user moves off this view 
     * @param direction; states what direction the the widget came to focus from ie if the up 
     *        key was pressed then DIRECTION_UP will be passed to this method to indicate that the 
     *        previously focused widget was below it
     **/ 
    public void setFocus( boolean focus ,int direction );
    
    /**
     * Widgets that require continous 'cycling' are returned to return true for this method so that 
     * the widget container can continue calling the cycle method even when the widget does not have focus 
     * e.g. widgets that perform animations 
     * @return
     */
    public boolean isAnimated(); 
    
    public boolean supportsTransitioning(); 
}
